﻿<UserControl x:Class="EtlViewer.Viewer.Controls.ExplorerTree"
             x:ClassModifier="internal"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:ctrls="clr-namespace:EtlViewer.Viewer.Controls"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0"  Height="25">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <TextBox Grid.Column="0" 
                     Name="txtRoot" 
                     HorizontalAlignment="Stretch" 
                     VerticalContentAlignment="Center"
                     ></TextBox>
            <Button Grid.Column="1" FontFamily="Marlett" Name="btnDirectory" Width="20" 
                    Click="btnDirectory_Click_1" 
                    HorizontalAlignment="Right" 
                    >4</Button>
            <Button Grid.Column="2" Style="{StaticResource ControlCommandButton}" Name="ClosePanel" Click="ClosePanel_Click_1" Width="15">r</Button>
        </Grid>
        <TreeView Grid.Row="1" x:Name="foldersTree" BorderThickness="0" Background="Transparent" Margin="5,10,0,0">
            <TreeView.ContextMenu>
                <ContextMenu>
                    <Menu>
                        <MenuItem Header="REFRESH" Name="Refresh" Click="Refresh_Click_1"></MenuItem>
                    </Menu>
                </ContextMenu>
            </TreeView.ContextMenu>
            <TreeView.Resources>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate DataType="ContentPresenter">
                                <StackPanel Orientation="Horizontal">
                                    <Image 
                                        Name="img" 
                                        Width="20" Height="20" 
                                        Stretch="Fill" 
                                        />
                                    <TextBlock Text="{Binding}" Margin="5,0"/>
                                </StackPanel>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding 
                                                RelativeSource={RelativeSource 
                                                Mode=FindAncestor, 
                                                AncestorType={x:Type TreeViewItem}}, 
                                                Path=(ctrls:TreeViewItemProps.IsRootLevel)}" 
                                                Value="True" >
                                        <Setter TargetName="img" 
                                                  Property="Source" 
                                                  Value="/Assets/Images/diskdrive.png" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding 
                                                RelativeSource={RelativeSource 
                                                Mode=FindAncestor, 
                                                AncestorType={x:Type TreeViewItem}}, 
                                                Path=(ctrls:TreeViewItemProps.IsFile)}" 
                                                Value="True" >
                                        <Setter TargetName="img" 
                                                  Property="Source" 
                                                  Value="/Assets/Images/file.png" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding  
                                                RelativeSource={RelativeSource  
                                                Mode=FindAncestor,  
                                                AncestorType={x:Type TreeViewItem}}, 
                                                Path=(ctrls:TreeViewItemProps.IsFile)}"  
                                                Value="False" >
                                        <Setter 
                                              TargetName="img" 
                                              Property="Source" 
                                              Value="/Assets/Images/folder.png" />
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TreeView.Resources>
        </TreeView>
    </Grid>
</UserControl>
